<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The EventListener class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="eventhttprequest.sendreplystart.html">EventHttpRequest::sendReplyStart</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="eventlistener.construct.html">EventListener::__construct</a></div>
 <div class="up"><a href="book.event.html">Event</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.eventlistener" class="reference">
 <h1 class="title">The EventListener class</h1>
 
 <div class="partintro"><p class="verinfo">(PECL event &gt;= 1.5.0)</p>

  <div class="section" id="eventlistener.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    Represents a connection listener.
   </p>
  </div>

  <div class="section" id="eventlistener.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">final</span>
      <strong class="classname">EventListener</strong>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventlistener.html#eventlistener.constants.opt-leave-sockets-blocking"><var class="varname">OPT_LEAVE_SOCKETS_BLOCKING</var></a></var>
     <span class="initializer"> = 1</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventlistener.html#eventlistener.constants.opt-close-on-free"><var class="varname">OPT_CLOSE_ON_FREE</var></a></var>
     <span class="initializer"> = 2</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventlistener.html#eventlistener.constants.opt-close-on-exec"><var class="varname">OPT_CLOSE_ON_EXEC</var></a></var>
     <span class="initializer"> = 4</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventlistener.html#eventlistener.constants.opt-reuseable"><var class="varname">OPT_REUSEABLE</var></a></var>
     <span class="initializer"> = 8</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventlistener.html#eventlistener.constants.opt-threadsafe"><var class="varname">OPT_THREADSAFE</var></a></var>
     <span class="initializer"> = 16</span>
    ;</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
     <span class="modifier">readonly</span>
     <span class="type">int</span>
      <var class="varname"><a href="class.eventlistener.html#eventlistener.props.fd">$<var class="varname">fd</var></a></var>
    ;</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><a href="eventlistener.construct.html" class="methodname">__construct</a></span>
    ( <span class="methodparam">
    <span class="type"><a href="class.eventbase.html" class="type EventBase">EventBase</a></span>
     <code class="parameter">$base</code>
   </span>
   , <span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$cb</code>
   </span>
   , <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$data</code>
   </span>
   , <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$flags</code>
   </span>
   , <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$backlog</code>
   </span>
   , <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$target</code>
   </span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span>
   <span class="methodname"><a href="eventlistener.disable.html" class="methodname">disable</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span>
   <span class="methodname"><a href="eventlistener.enable.html" class="methodname">enable</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="eventlistener.getbase.html" class="methodname">getBase</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">bool</span>
   <span class="methodname"><a href="eventlistener.getsocketname.html" class="methodname">getSocketName</a></span>
    ( <span class="methodparam">
    <span class="type">string</span>
     <code class="parameter reference">&$address</code>
   </span>
   [, <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter reference">&$port</code>
   </span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="eventlistener.setcallback.html" class="methodname">setCallback</a></span>
    ( <span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$cb</code>
   </span>
   [, <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$arg</code>
    <span class="initializer"> = <strong><code>NULL</code></strong></span>
   </span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="eventlistener.seterrorcallback.html" class="methodname">setErrorCallback</a></span>
    ( <span class="methodparam">
    <span class="type">string</span>
     <code class="parameter">$cb</code>
   </span>
   )</div>

   }</div>

  </div>
  <div class="section" id="eventlistener.props">
   <h2 class="title">属性</h2>
   <dl>

    
     <dt id="eventlistener.props.fd">
      <var class="varname"><var class="varname">fd</var></var>
     </dt>

     <dd>

      <p class="para">
       Numeric file descriptor of the underlying socket. (Added in
       <em>event-1.6.0</em>
       .)
      </p>
     </dd>

    
   </dl>

  </div>

  <div class="section" id="eventlistener.constants">
   <h2 class="title">预定义常量</h2>
   <dl>

    
     <dt id="eventlistener.constants.opt-leave-sockets-blocking">
      <strong><code>EventListener::OPT_LEAVE_SOCKETS_BLOCKING</code></strong>
     </dt>

     <dd>

      <p class="para">
       By default Libevent turns underlying file descriptors, or sockets, to
       non-blocking mode. This flag tells to leave them non-blocking.
      </p>
     </dd>

    
    
     <dt id="eventlistener.constants.opt-close-on-free">
      <strong><code>EventListener::OPT_CLOSE_ON_FREE</code></strong>
     </dt>

     <dd>

      <p class="para">
       If this option is set, the connection listener closes its underlying
       socket when the
       <strong class="classname">EventListener</strong>
       object is freed.
      </p>
     </dd>

    
    
     <dt id="eventlistener.constants.opt-close-on-exec">
      <strong><code>EventListener::OPT_CLOSE_ON_EXEC</code></strong>
     </dt>

     <dd>

      <p class="para">
       If this option is set, the connection listener sets the close-on-exec
       flag on the underlying listener socket. See platform documentation for
       <em>fcntl</em>
       and
       <strong><code>FD_CLOEXEC</code></strong>
       for more information.
      </p>
     </dd>

    
    
     <dt id="eventlistener.constants.opt-reuseable">
      <strong><code>EventListener::OPT_REUSEABLE</code></strong>
     </dt>

     <dd>

      <p class="para">
       By default on some platforms, once a listener socket is closed, no
       other socket can bind to the same port until a while has passed.
       Setting this option makes Libevent mark the socket as reusable, so that
       once it is closed, another socket can be opened to listen on the same
       port.
      </p>
     </dd>

    
    
     <dt id="eventlistener.constants.opt-threadsafe">
      <strong><code>EventListener::OPT_THREADSAFE</code></strong>
     </dt>

     <dd>

      <p class="para">
       Allocate locks for the listener, so that it’s safe to use it from
       multiple threads.
      </p>
     </dd>

    
   </dl>

  </div>

 </div>

 




































<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="eventlistener.construct.html">EventListener::__construct</a> — Creates new connection listener associated with an event base</li><li><a href="eventlistener.disable.html">EventListener::disable</a> — Disables an event connect listener object</li><li><a href="eventlistener.enable.html">EventListener::enable</a> — Enables an event connect listener object</li><li><a href="eventlistener.getbase.html">EventListener::getBase</a> — Returns event base associated with the event listener</li><li><a href="eventlistener.getsocketname.html">EventListener::getSocketName</a> — Retreives the current address to which the
  listener's socket is bound.</li><li><a href="eventlistener.setcallback.html">EventListener::setCallback</a> — The setCallback purpose</li><li><a href="eventlistener.seterrorcallback.html">EventListener::setErrorCallback</a> — Set event listener's error callback</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="eventhttprequest.sendreplystart.html">EventHttpRequest::sendReplyStart</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="eventlistener.construct.html">EventListener::__construct</a></div>
 <div class="up"><a href="book.event.html">Event</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
